<?php

declare (strict_types=1);
namespace App\Model;

use Psr\SimpleCache\InvalidArgumentException;

/**
 * @property string $name
 * @property string $content
 */
class SysSetting extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'sys_setting';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['name', 'content'];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [];


    /**
     * 获取系统设置
     * @return array|mixed
     * @throws InvalidArgumentException
     */
    public static function sysInfo(){


        $cacheKey = "sysSettingInfo";

        $sysInfo = cache()->get($cacheKey);

        if (is_null($sysInfo)){

            $list = self::get()->toArray();

            if (!empty($list)){

                $sysInfo = array_column($list,'content','name');

                cache()->set($cacheKey,$sysInfo,3600);
            }


        }

        return $sysInfo??[];



    }
}
